package com.ethink.order.facadeImpl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ethink.order.api.SaleOrderFacade;
import com.ethink.order.api.info.SaleDetailOrderInfo;
import com.ethink.order.api.info.SaleOrderInfo;
import com.ethink.order.api.model.SaleOrderModeQueryModel;
import com.ethink.order.api.model.SaleOrderPageQueryModel;
import com.ethink.order.api.request.*;
import com.ethink.order.api.response.SaleOrderAddResponse;
import com.ethink.order.api.response.SaleOrderDetailResponse;
import com.ethink.order.manager.SaleManager;
import com.ethink.order.service.SaleDetailOrderService;
import com.ethink.order.service.SaleOrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * TOC销售单 Facade接口实现
 *
 * @author default
 * @date 2022-11-22
 */
@RestController
@Slf4j
@RequestMapping("order-service/facade/v1/saleOrder")
public class SaleOrderFacadeImpl implements SaleOrderFacade {

    @Autowired
    private SaleOrderService saleOrderService;

    @Autowired
    private SaleDetailOrderService saleDetailOrderService;

    @Override
    public SaleOrderAddResponse addSaleOrder(SaleOrderAddRequest request) {
        return saleOrderService.addSaleOrder(request, true);
    }

    @Autowired
    private SaleManager saleManager;

    @Override
    public Page<SaleOrderPageQueryModel> pageQuerySaleOrder(SaleOrderQueryRequest request) {
        return saleOrderService.pageQuerySaleOrder(request);
    }

    @Override
    public Integer deleteSaleOrder(Long id) {
        return saleOrderService.deleteSaleOrder(id);
    }

    @Override
    public SaleOrderDetailResponse getSaleOrderById(Long id) {
        return saleOrderService.getSaleOrderById(id);
    }

    @Override
    public SaleOrderDetailResponse getSaleOrderByOrderNo(String orderNo) {
        return saleOrderService.getSaleOrderByOrderNo(orderNo);
    }


    @Override
    public Integer updateSaleOrder(SaleOrderUpdateRequest request) {
        return saleManager.updateSaleOrder(request);
    }

    @Override
    public Integer updateStatus(SaleOrderUpdateStatusRequest request) {
        return saleOrderService.updateStatus(request);
    }

    @Override
    public void createFinish(List<SaleOrderAdd2Request> add2RequestList) {
        saleManager.createFinish(add2RequestList);
    }

    @Override
    public List<SaleDetailOrderInfo> queryDetailListByOrderNo(String orderNo) {
        return saleDetailOrderService.queryDetailListByOrderNo(orderNo);
    }

    @Override
    public List<String> querySaleOrderDetailOrderNoByOrderNo(List<String> orderNos) {
        return saleDetailOrderService.querySaleOrderDetailOrderNoByOrderNo(orderNos);
    }

    @Override
    public Page<SaleOrderModeQueryModel> pageSaleOrderModeQuery(SaleOrderModeQueryRequest request) {
        return saleOrderService.pageSaleOrderModeQuery(request);
    }

    @Override
    public SaleOrderDetailResponse getSaleOrderByShopOrderNo(String saleSubChannel, String shopOrderNo) {
        return saleOrderService.getSaleOrderByShopOrderNo(saleSubChannel, shopOrderNo);
    }

    @Override
    public SaleOrderInfo selectSaleOrderById(Integer id) {
        return saleOrderService.selectSaleOrderById(id);
    }
}